<style lang="css" scoped>
.el-table .cell .el-tooltip   {
  white-space: pre-line;
}
</style>

<template>
    <el-card shadow="never">
      <!-- 搜索表单 -->
      <el-form
        :model="where"
        label-width="77px"
        class="ele-form-search"
        @keyup.enter.native="reload"
        @submit.native.prevent>
        <el-row :gutter="15">

          <el-col :lg="8" :md="12">
            <el-form-item label="日期:">
              <el-date-picker
                style="width: 100%"
                v-model="where.time_range"
                type="datetimerange"
                value-format="yyyy-MM-dd HH:mm:ss"
                label-format="yyyy-MM-dd HH:mm:ss"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>

          <el-col :lg="6" :md="12">
            <div class="ele-form-actions">
              <el-button
                type="primary"
                icon="el-icon-search"
                class="ele-btn-icon"
                @click="reload">查询
              </el-button>
              <el-button @click="reset">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
      <!-- 数据表格 -->
      <ele-pro-table
        ref="table"
        :where="where"
        :datasource="url"
        :columns="columns"
        :selection.sync="selection"
        height="calc(100vh - 315px)">
         <!-- 搜索场景 -->
         <template slot="type" slot-scope="{row}">
          <el-tag v-if="row.type === 1" type="success" size="small">签到</el-tag>
          <el-tag v-if="row.type === 2" type="warning" size="small">补签</el-tag>
        </template>
      </ele-pro-table>
    </el-card>
</template>

<script>
import {mapGetters} from "vuex";

export default {
  name: 'StatisticsBoxBanner',
  computed: {
    ...mapGetters(["permission"]),
  },
  data() {
    return {
      // 表格数据接口
      url: '/boxSigninLog/index',
      // 表格列配置
      columns: [
        {
          columnKey: 'selection',
          type: 'selection',
          width: 45,
          align: 'center',
          fixed: "left"
        },
        {
          prop: 'id',
          label: 'ID',
          width: 60,
          align: 'center',
          showOverflowTooltip: true,
          fixed: "left"
        },
        {
          prop: 'member_id',
          label: '用户ID',
          width: 160,
          align: 'center',
          showOverflowTooltip: true,
          fixed: "left"
        },
        {
          prop: 'score',
          label: '积分数',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center',
        },
        {
          prop: 'sign_in_time',
          label: '签到日期',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center',
        },

        {
          prop: 'type',
          label: '类型',
          align: 'center',
          minWidth: 100,
          showOverflowTooltip: true,
          slot: 'type',
        },

        {
          prop: 'createtime',
          label: '创建时间',
          showOverflowTooltip: true,
          minWidth: 200,
          align: 'center',
          formatter: (row, column, cellValue) => {
            return this.$util.toDateString(cellValue);
          }
        }
      ],
      // 表格搜索条件
      where: {},
      // 表格选中数据
      selection: [],
    };
  },
  methods: {
    /* 刷新表格 */
    reload() {
      this.$refs.table.reload({where: this.where});
    },
    /* 重置搜索 */
    reset() {
      this.where = {'show_type': 3};
      this.reload();
    },

  }
}
</script>

<style scoped>
</style>
